Common tasks for modern computer systems include audio and video processing. In such systems, the audio and/or video data may be received from a storage of a system or a medium such as a DVD. In other examples, the incoming media stream can be received from the Internet. The received media stream from any of these sources typically is in a compressed form to minimize bandwidth/storage required for distribution/processing.
Common media compression algorithms use a combination of variable size symbols to quantize symbol values to achieve a targeted compression. Hence, media stream processing typically performs bit parsing to extract the variable size symbols as the first step in processing. Such bit level symbol identification and extraction is generally performed on traditional general purpose processors and microcontrollers. However, the lack of specific bit level processing infrastructure on these engines leads to comparatively complex code and flow control. Traditional processors and microcontrollers operate on a byte, word, or double word data paths. As such, media processing code typically uses an accumulator which is loaded from the bitstream and then consumed in a specific direction (e.g., most significant bit (MSB) to least significant bit (LSB)). As symbols are found, the accumulator bits are shifted out and the next set of bits from the bitstream is loaded into the accumulator with splicing (so that the accumulator appears like a moving window superimposed on the bitstream).
In most cases, audio/video data is also packaged in transport stream packets, which complicates parsing by breaking up the audio/video data into chunks that are then prefixed with arbitrary size headers. This packaging can lead to symbols spanning multiple packets with packet header bits interspersed between valid symbol bits. Accordingly, the parsing operations are computationally very expensive and require significant code in order to account for the interleaving of data among packet headers and other undesired information.